package fy.mdm.operator;

import com.seeyon.v3x.services.flow.bean.FlowExport;
import com.seeyon.v3x.services.form.bean.ValueExport;
import fy.form.listen.operate.AForm_Save_Operator;
import fy.form.listen.operate.IFormOperator;
import fy.mdm.bean.CodingChangesBean;
import fy.mdm.dao.CodingChangesDao;
import java.util.ArrayList;
import java.util.List;

public class CodingChangesOperator
        extends AForm_Save_Operator
        implements IFormOperator
{
    private CodingChangesBean bean = new CodingChangesBean();
    private List<String> oldProductCodeList = new ArrayList();
    private List<String> newProductCode = new ArrayList();
    private List<String> newProductName = new ArrayList();
    private List<String> newModelType = new ArrayList();
    private List<String> newCustomerPartNumber = new ArrayList();
    private List<String> state = new ArrayList();
    private List<String> produktklassifizierung = new ArrayList();

    public String getFormName()
    {
        return "产品编码变更申请表";
    }

    protected void parseOtherField_FirstStep(FlowExport flowExport) {}

    protected void parseValueExport(ValueExport ve)
    {
        String fieldName = ve.getDisplayName();
        if ("原编码".equals(fieldName)) {
            this.oldProductCodeList.add(ve.getValue());
        } else if ("需要修改的编码".equals(fieldName)) {
            this.newProductCode.add(ve.getValue());
        } else if ("变更后-产品名称".equals(fieldName)) {
            this.newProductName.add(ve.getValue());
        } else if ("变更后-车型型号".equals(fieldName)) {
            this.newModelType.add(ve.getValue());
        } else if ("变更后-客户零件号".equals(fieldName)) {
            this.newCustomerPartNumber.add(ve.getValue());
        } else if ("变更状态".equals(fieldName)) {
            this.state.add(ve.getValue());
        } else if ("产品分类".equals(fieldName)) {
            this.produktklassifizierung.add(ve.getValue());
        }
    }

    protected boolean save()
    {
        this.bean.setOldProductCode(this.oldProductCodeList);
        this.bean.setNewProductCode(this.newProductCode);
        this.bean.setNewProductName(this.newProductName);
        this.bean.setNewModelType(this.newModelType);
        this.bean.setNewCustomerPartNumber(this.newCustomerPartNumber);
        this.bean.setState(this.state);
        this.bean.setProduktklassifizierung(this.produktklassifizierung);

        CodingChangesDao CodingChangesDao = new CodingChangesDao();
        CodingChangesDao.setCodingChangesBean(this.bean);
        try
        {
            return CodingChangesDao.ProductCodingChanges();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            this.bean = null;
        }
        return this.success;
    }
}
